<style>
    .images {
        display: inline-block;
    }

    .image {
        width: 60px;
        height: 60px;
    }
</style>
<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">
        <div class="layui-tab">
            <ul class="layui-tab-title">
                {if ($row.type == 0)}
                <li class="layui-this" value="0">通用券</li>
                <li value="1">商品券</li>
                {else /}
                <li value="0">通用券</li>
                <li class="layui-this" value="1">商品券</li>
                {/if}
            </ul>
        </div>
        <input type="hidden" id="type" name="type" value="0">
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" class="layui-input" lay-verify="required" placeholder="请输入优惠券名称"
                       value="{$row.title|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券面额</label>
            <div class="layui-input-block">
                <input type="text" name="coupon_price" class="layui-input" lay-verify="required" placeholder="请输入优惠券面额"
                       value="{$row.coupon_price|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最低消费金额</label>
            <div class="layui-input-block">
                <input type="text" name="use_min_price" class="layui-input" lay-verify="required"
                       placeholder="请输入最低消费金额" value="{$row.use_min_price|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">折扣力度</label>
            <div class="layui-input-block">
                <input type="text" name="discount" class="layui-input" lay-verify="required"
                       placeholder="折扣力度 例如：98  代表98折" value="{$row.discount|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠方式</label>
            <div class="layui-input-block">
                {if($row.discount_method == "满减")}
                <input type="radio" name="discount_method" value="1" title="满减"  checked>
                {else /}
                <input type="radio" name="discount_method" value="1" title="满减">
                {/if}
                {if($row.discount_method == "直减")}
                <input type="radio" name="discount_method" value="2" title="直减"  checked>
                {else /}
                <input type="radio" name="discount_method" value="2" title="直减">
                {/if}
                {if($row.discount_method == "折扣")}
                <input type="radio" name="discount_method" value="3" title="折扣"  checked>
                {else /}
                <input type="radio" name="discount_method" value="3" title="折扣">
                {/if}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">兑换消耗积分</label>
            <div class="layui-input-block">
                <input type="text" name="integral" class="layui-input" lay-verify="required" placeholder="请输入兑换消耗积分"
                       value="{$row.integral|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券有效期限（单位：天）</label>
            <div class="layui-input-block">
                <input type="text" name="coupon_time" class="layui-input" lay-verify="required"
                       placeholder="请输入优惠券有效期限（单位：天）" value="{$row.coupon_time|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券领取开启时间</label>
            <div class="layui-input-block">
                <input type="datetime-local" name="start_time" class="layui-input" lay-verify="required"
                       placeholder="请输入优惠券领取开启时间" value="{$row.start_time|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券领取结束时间</label>
            <div class="layui-input-block">
                <input type="datetime-local" name="end_time" class="layui-input" lay-verify="required" placeholder="请输入优惠券领取结束时间"
                       value="{$row.end_time|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券领取数量</label>
            <div class="layui-input-block">
                <input type="text" name="total_count" class="layui-input" lay-verify="required" placeholder="请输入优惠券领取数量"
                       value="{$row.total_count|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券剩余领取数量</label>
            <div class="layui-input-block">
                <input type="text" name="remain_count" class="layui-input" lay-verify="required"
                       placeholder="请输入优惠券剩余领取数量" value="{$row.remain_count|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否无限张</label>
            <div class="layui-input-block">
                    {if($row.is_permanent == 1)}
                    <input type="checkbox" checked="" value="1" name="is_permanent" lay-skin="switch" lay-filter="switchTest" lay-text="是|否">
                    {else /}
                    <input type="checkbox" value="1" name="is_permanent" lay-skin="switch" lay-filter="switchTest" lay-text="是|否">
                    {/if}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否首次关注赠送</label>
            <div class="layui-input-block">
                {if($row.is_give_subscribe)}
                <input type="checkbox" checked="" value="1" name="is_give_subscribe" lay-skin="switch" lay-filter="switchTest" lay-text="是|否">
                {else /}
                <input type="checkbox" value="1" name="is_give_subscribe" lay-skin="switch" lay-filter="switchTest" lay-text="是|否">
                {/if}
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态</label>
            <div class="layui-input-block">
                {if($row.status)}
                <input type="checkbox" checked="" value="1" name="status" lay-skin="switch" lay-filter="switchTest" lay-text="开启|关闭">
                {else /}
                <input type="checkbox" value="1" name="is_give_subscribe" lay-skin="switch" lay-filter="switchTest" lay-text="开启|关闭">
                {/if}
            </div>
        </div>
        <div class="layui-form-item" id="product">
            <label class="layui-form-label">可用商品id</label>
            <div id="images">
                {if(isset($image))}
                {foreach $image as $v}
                <img src="{$v}" class='image' />
                {/foreach}
                {/if}
                <img src="__STATIC__/admin/images/+.jpg" id="image" data-method="offset" style="border: 1px dashed black;" class="image">
            </div>
            <input type="hidden" id="product_id" name="product_id" value="{$row.product_id|default=''}">
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" name="sort" class="layui-input" lay-verify="required" placeholder="请输入排序" value="{$row.sort|default=''}">
            </div>
        </div>
        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>
    </form>
</div>

<script>
    layui.use(['jquery', 'form', 'upload', 'element', 'layer'], function () {
        var $ = layui.jquery;
        var form = layui.form,
            element = layui.element,
            layer = layui.layer;

        var active = {
            offset: function(othis) {
                var type = othis.data('type')
                    , text = othis.text();

                layer.open({
                    type: 2
                    , area: ['800px','600px']
                    , offset: type //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
                    , id: 'layerDemo' + type //防止重复弹出
                    , content: "{:url('store.goods/selectGoods')}"
                    , btnAlign: 'c' //按钮居中
                    , shade: 0 //不显示遮罩
                    , yes: function () {
                        layer.closeAll();
                    }
                });
            }
        }

        $('.image').on('click', function(){
            var othis = $(this), method = othis.data('method');
            active[method] ? active[method].call(this, othis) : '';
        });
        let type = $('#type').val();
        if (type != 0) {
            $('#product').show();
        }else {
            $('#product').hide();
        }

        $("li").click(function () {
            let type = $(this).val();
            $('#type').val(type);
            if (type == 1) {
                $('#product').show();
            }else {
                $('#product').hide();
            }
        })

        // form.on('select(rule)', function (res) {
        //     $.ajax({
        //         url: "{:url('ruleList')}",
        //         data: {id: res.value},
        //         dataType: "json",
        //         type: "get",
        //         success: function (res) {
        //             vm.items = res.data[0].specifica_value;
        //         }
        //     })
        // })
    })
</script>
<!--
<div class="layuimini-container">
    <form id="app-form" class="layui-form layuimini-form">
        
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券名称</label>
            <div class="layui-input-block">
                <input type="text" name="title" class="layui-input" lay-verify="required" placeholder="请输入优惠券名称" value="{$row.title|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券面额</label>
            <div class="layui-input-block">
                <input type="text" name="coupon_price" class="layui-input" lay-verify="required" placeholder="请输入优惠券面额" value="{$row.coupon_price|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">最低消费金额</label>
            <div class="layui-input-block">
                <input type="text" name="use_min_price" class="layui-input" lay-verify="required" placeholder="请输入最低消费金额" value="{$row.use_min_price|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">兑换消耗积分</label>
            <div class="layui-input-block">
                <input type="text" name="integral" class="layui-input" lay-verify="required" placeholder="请输入兑换消耗积分" value="{$row.integral|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券有效期限（单位：天）</label>
            <div class="layui-input-block">
                <input type="text" name="coupon_time" class="layui-input" lay-verify="required" placeholder="请输入优惠券有效期限（单位：天）" value="{$row.coupon_time|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券领取开启时间</label>
            <div class="layui-input-block">
                <input type="text" name="start_time" class="layui-input" lay-verify="required" placeholder="请输入优惠券领取开启时间" value="{$row.start_time|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券领取结束时间</label>
            <div class="layui-input-block">
                <input type="text" name="end_time" class="layui-input" lay-verify="required" placeholder="请输入优惠券领取结束时间" value="{$row.end_time|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券领取数量</label>
            <div class="layui-input-block">
                <input type="text" name="total_count" class="layui-input" lay-verify="required" placeholder="请输入优惠券领取数量" value="{$row.total_count|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券剩余领取数量</label>
            <div class="layui-input-block">
                <input type="text" name="remain_count" class="layui-input" lay-verify="required" placeholder="请输入优惠券剩余领取数量" value="{$row.remain_count|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否无限张(0：否 1：是)</label>
            <div class="layui-input-block">
                <input type="text" name="is_permanent" class="layui-input" lay-verify="required" placeholder="请输入是否无限张(0：否 1：是)" value="{$row.is_permanent|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否首次关注赠送 （0：否 1：是）</label>
            <div class="layui-input-block">
                <input type="text" name="is_give_subscribe" class="layui-input" lay-verify="required" placeholder="请输入是否首次关注赠送 （0：否 1：是）" value="{$row.is_give_subscribe|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">状态（1：正常 0：未开启 -1：已无效）</label>
            <div class="layui-input-block">
                <input type="text" name="status" class="layui-input" lay-verify="required" placeholder="请输入状态（1：正常 0：未开启 -1：已无效）" value="{$row.status|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">优惠券类型（0：通用券 1：商品券）</label>
            <div class="layui-input-block">
                <input type="text" name="type" class="layui-input" lay-verify="required" placeholder="请输入优惠券类型（0：通用券 1：商品券）" value="{$row.type|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">可用商品id</label>
            <div class="layui-input-block">
                <input type="text" name="product_id" class="layui-input" lay-verify="required" placeholder="请输入可用商品id" value="{$row.product_id|default=''}">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">排序</label>
            <div class="layui-input-block">
                <input type="text" name="sort" class="layui-input" lay-verify="required" placeholder="请输入排序" value="{$row.sort|default=''}">
            </div>
        </div>
        <div class="hr-line"></div>
        <div class="layui-form-item text-center">
            <button type="submit" class="layui-btn layui-btn-normal layui-btn-sm" lay-submit>确认</button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
        </div>

    </form>
</div>-->
